
var array = [];

console.log(array.length)

array.push(1)
array.push(2)
array.push(3)
array.push(3)
array.push(4)
array.push(5)

console.log("pop")
console.log(array.pop())

console.log("toString")
console.log(array.toString())

//会调用元素的toLocaleString
console.log("toLocaleString")
console.log(array.toLocaleString())

//将2个数组连在一起,返回新生成数组，不改变原数组
console.log("concat")
console.log(array.concat([1, 2], [2, 3]))
console.log(array)

//返回用字符串连接的数组
console.log("join")
console.log(array.join("-"))

//返回反转后的数组 改变原数组
console.log("reverse")
console.log(array.reverse())
array.reverse()

//返回删除的元素
console.log("shift")
console.log(array.shift())

//返回切片的元素
console.log("slice")
array.slice(0, 2).forEach(a => console.log(a))


//返回删除的数组，会修改原数组
console.log(array)
console.log("splice")
console.log(array.splice(0,0,9,8,7)) // 增加 返回[]
console.log(array)
console.log(array.splice(1,2,77,88,99)) // 改
console.log(array)
console.log(array.splice(1,2)) // 删除
console.log(array)



console.log("-------------------------------------------------------------------------------------------")

var arr2 = [9,8,7,6,5,4,3]

//无返回值
console.log('forEach')
arr2.forEach((item,index,array) => {
    arr2[index] = item +10
})
console.log(arr2)

// 返回新数组
console.log("map")
var temp = arr2.map((item,index,array)=>{
    return item +3
})
console.log(temp)

